package com.wfm.leetcode.editor.cn;
public class PNine05按奇偶排序数组{
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int[] sortArrayByParity(int[] nums) {
        int i = 0 ;
        int j = nums.length-1;
        while (i<j){
            if(nums[i]%2!=0){
                swap(nums,i,j);
                j--;
            }else {
                i++;
            }
        }
        return nums;
    }
    void swap(int[] nums,int i,int j){
        int tmp = nums[i];
        nums[i]=nums[j];
        nums[j]=tmp;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

    public static void main(String[] args) { 
        Solution solution = new PNine05按奇偶排序数组().new Solution();
    }
}